//
//  SearchLearCell.m
//  Cunli
//
//  Created by lilubin on 15/7/21.
//  Copyright (c) 2015年 lilubin. All rights reserved.
//

#import "SearchLearCell.h"
#import "UIImageView+WebCache.h"
#import "SearchInfoLearnModel.h"
#import "DeviceInfoClass.h"

@implementation SearchLearCell

- (void)layoutSubviews
{
    [super layoutSubviews];
                                                        
    NSURL *picURL = [NSURL URLWithString:_learnModel.pic];
    [_titleImgView setImageWithURL:picURL placeholderImage:[UIImage imageNamed:@"default_news"]];
    
    _titleLabel.text = _learnModel.title;
    _authorLabel.text = _learnModel.au_or_sper;
    _introduceLabel.text = _learnModel.introduce;
    _typeLabel.text = _learnModel.modelTypename;
    
    [_typeLabel setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"searchRightBg.png"]]];
    
    if ([DeviceInfoClass getCurrentDeviceDetailVersion] == DeviceInfoVersioniPhone4s || [DeviceInfoClass getCurrentDeviceDetailVersion] == DeviceInfoVersioniPhone5s) {
        [_titleLabel setFont:[UIFont systemFontOfSize:16.0f]];
        [_introduceLabel setFont:[UIFont systemFontOfSize:13.0f]];
        [_authorLabel setFont:[UIFont systemFontOfSize:13.0f]];
    }
}

- (void)setLearnModel:(SearchInfoLearnModel *)learnModel
{
    if (_learnModel != learnModel) {
        _learnModel = learnModel;
        NSURL *picURL = [NSURL URLWithString:_learnModel.pic];
        [_titleImgView setImageWithURL:picURL placeholderImage:[UIImage imageNamed:@"default_news"]];
        
        _titleLabel.text = _learnModel.title;
        _authorLabel.text = _learnModel.au_or_sper;
        _introduceLabel.text = _learnModel.introduce;
        _typeLabel.text = _learnModel.modelTypename;
    }

}
@end
